<template>
	<view>
		<scroll-view scroll-y="true">
			<view class="top_box" :style="{height:`${125.5+statusBarHeight}px`}">
				<image class="bg" :style="{height:`${125.5+statusBarHeight}px`}" :src="$fun.imgUrl('/webimage/index_top.png')" mode=""></image>
				<view class="top_info" :style="{marginTop:`${46+statusBarHeight*2}rpx`}">
					<view class="l">
						<view class="img">
							<image :src="$fun.imgUrl(userInfo.avatar)" @click="uploadPic" mode=""></image>
						</view>
						<view class="box" style="display: flex;flex-direction: column;">
							<view class="tel">
								{{userInfo.nickname}}
							</view>
							<view class="tel">
								{{userInfo.mobile}}
							</view>
						</view>
						
					</view>
					<!-- #ifndef MP-WEIXIN -->
					<view class="r">
						<image @click="jump('/pageA/set')" src="/static/newProject/set.png" mode=""></image>
					</view>
					<!-- #endif -->

					<!-- <block v-for="(item,index) in balanceList" :key="index">
						<view class="wallet ab" v-if="index==0">
							<view class="top_box1">
								<view class="l">
									<view class="text">
										{{item.name}}
									</view>
									<image src="/static/newProject/eye.png" mode=""></image>
								</view>
								<view class="r">
									<view class="button">
									</view>
								</view>
							</view>
							<view class="wallet_box">
								<view class="wallet_item">
									<view>余额 </view>
									<view>{{item.money}}</view>
								</view>
								<view class="wallet_item" @click="jump(`/pages/user/wallet/wallet`)">
									<view>累计收益 </view>
									<view>{{item.total_money}}</view>
								</view>
							</view>
						</view>
					</block>
 -->
				</view>

			</view>
			<view  :style="{height:`${100+statusBarHeight}px`}">

			</view>
			<view class="vip_box" >
				<view class="vip-card-box">
					<text>{{userInfo.levelname}}</text>
					<text>去升级</text>
				</view>
				<image src="/static/arc.png" class="vip_bg" style="width: 100%; height: 18px;" mode=""></image>
			</view>
			<view class="tj-sction">
				<view class="tj-item" v-for="(item,index) in balanceList" :key='index' @click="onDetali(item)">
					<text class="num">{{item.money}}</text>
					<text>{{item.name}}</text>
				</view>
			</view>
			<!-- 订单 -->
			<view class="order-section">
				<view class="order-item" @click="$fun.jump('/pageA/order/order?state=0')"
					hover-class="common-hover" :hover-stay-time="50">
					<text class="yticon icon-shouye"></text>
					<text>全部订单</text>
				</view>
				<view class="order-item" @click="$fun.jump('/pageA/order/order?state=1')"
					hover-class="common-hover" :hover-stay-time="50">
					<text class="yticon icon-daifukuan"></text>
					<text>待付款</text>
				</view>
				<view class="order-item" @click="$fun.jump('/pageA/order/order?state=2')"
					hover-class="common-hover" :hover-stay-time="50">
					<text class="yticon icon-yishouhuo"></text>
					<text>待收货</text>
				</view>
				<view class="order-item" @click="$fun.jump('/pageA/order/order?state=3')"
					hover-class="common-hover" :hover-stay-time="50">
					<text class="yticon icon-shouhoutuikuan"></text>
					<text>已完成</text>
				</view>
			</view>
						<block v-for="(item,index) in list" :key="index">
				<view class="wallet1" >
					<view class="top_box1">
						<view class="l">
							<view class="text">
								{{item.t}}
							</view>
							<!-- <image src="/static/newProject/eye.png" mode=""></image> -->
						</view>
						<view class="r">
							<view class="button">
							</view>
						</view>
					</view>
					<view class="wallet_box" >
						<view class="wallet_item" >
							<view>{{item.t1Num}}</view>
							<view>{{item.t1}} </view>
						</view>
						<view class="wallet_item" @click="$fun.jump(`/pageA/userLine?type=${item.key}&name=流量图查看`,0,0)">
							<image src="/static/k.jpg" mode=""></image>
							<view>流量图查看 </view>
							<!-- <view>{{item.total_money}}</view> -->
						</view>
					</view>
				</view>
			</block>
			<view class="imgs_box">
				<image src="/static/newProject/imgs1.png" mode=""
					@click="jump(`/pageB/noticeList/noticeInfo?name=代理指南&type=17`)"></image>
				<image :src="$fun.imgUrl('webimage/imgs2.png')" mode="" @click="jump(`/pageA/share`)"></image>
			</view>
					<!-- <view class="user_content">
				<view class="user_item">
					<image src="/static/newProject/user/ioc-02.png" mode=""></image>
					<view class="text">
						我的订单
					</view>
				</view>
				<view class="user_item">
					<image src="/static/newProject/user/ioc-03.png" mode=""></image>
					<view class="text">
						我的激活码
					</view>
				</view>
				<view class="user_item" @click="jump(`/pages/index/noticeList/noticeList?type=0&name=公告`)">
					<image src="/static/newProject/user/ioc-04.png" mode=""></image>
					<view class="text">
						公告中心
					</view>
				</view>
			</view> -->
			<view class="user_content1">
				<view class="user_item" v-for="(item,index) in ywList" :key="index" @click="jump(item.url)">
					<image :src="$fun.imgUrl(item.image)" mode=""></image>
					<view class="text">
						{{item.name}}
					</view>
				</view>
			</view>
		</scroll-view>
		<view style="height: 170upx;">

		</view>
		<TabBar :tabBarShow="4"></TabBar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				balanceList: [],
				list:[],
				ywList: [],
				statusBarHeight:0
			};
		},
		// 分享好友
		onShareAppMessage() {
			return {
			      title: '鲲鱬云',
			      path: JSON.parse(uni.getStorageSync('gitH5Qrcode')), 
			    }
		},
		// 分享朋友圈
		onShareTimeline(){
			return {
			      title: '鲲鱬云',
			      query: JSON.parse(uni.getStorageSync('gitH5Qrcode')), 
			    }
		},
		async onShow() {
			const phoneInfo = uni.getSystemInfoSync();// 获取手机系统信息
			this.statusBarHeight = phoneInfo.statusBarHeight
			await this.$fun.ajax.post('user/index', {}).then(res => {
				if (res.code == 1) {
					this.userInfo = res.data
				}
			})
			await this.$fun.ajax.post('user/balance', {}).then(res => {
				if (res.code == 1) {
					this.balanceList = res.data
				}
			})
			await this.$fun.ajax.post('index/category', {}).then(res => {
				if (res.code == 1) {
					this.ywList = res.data
				}
			})
			await this.$fun.ajax.post('user/incomeKinfo', {}).then(res => {
				if (res.code == 1) {
					this.list = [
						
							{
								t:'全网流量查询',
								t1:'昨日累计流量',
								t1Num:res.data.totalflow,
								key:1
							},
							{
								t:'个人流量查询',
								t1:'昨日流量贡献值',
								t1Num:res.data.flow,
								key:2
							},
							{
								t:'火豆奖励查询',
								t1:'昨日火豆奖励值',
								t1Num:res.data.bean,
								key:3
							},
						
					]
				}
			})
		},
		methods: {
			jump(url) {
				if(url.indexOf('http')!=-1){
					this.$fun.jump(`/pageA/webView/webView?url=${url}&name=网络测速`,0,0)
				}else{
					this.$fun.jump(url,0,0)
				}
			},
			uploadPic(){
				let _this = this
				uni.chooseImage({
					count: 1,
					success: res => {
						let tempFilePaths = res.tempFilePaths[0]
						uni.uploadFile({
							url: this.$baseUrl + '/api/common/upload', // 仅为示例，非真实的接口地址 
							filePath: tempFilePaths,
							name: 'file',
							header: {
								token: uni.getStorageSync('token')
							},
							success(res) {
								var res = JSON.parse(res.data)
								let userDate = {
									avatar: res.data.url,
								}
								 _this.$fun.ajax.post('user/profile',{ ...userDate
								}).then(res1 => {
									if (res.code == 1) {
										_this.userInfo.avatar = res.data.fullurl
										
									}
								})
							},
						})
					}
				})
			},
			onDetali(item) {
				this.$fun.jump('/pageA/wallet/wallet')
			}
		}
	}
</script>

<style lang="scss">
	.top_box {
		position: absolute;
		top: 0;
		width: 100%;
		height: 251rpx;
		box-sizing: border-box;

		image.bg {
			width: 100%;
			height: 100%;
			position: absolute;
			top: 0;
			z-index: -100;
		}

		.top_info {
			margin-top: 46rpx;
			padding: 0 30rpx;
			box-sizing: border-box;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			.l {
				display: flex;
				align-items: center;

				.img {
					width: 120rpx;
					height: 120rpx;
					background: #EEEEEE;
					border-radius: 50%;
					display: flex;
					justify-content: center;
					align-items: center;

					image {
						width: 79rpx;
						height: 85rpx;
					}
				}

				.tel {
					margin-left: 17rpx;
					font-size: 30rpx;
					font-family: Microsoft YaHei;
					font-weight: bold;
					color: #F6F6F6;
				}
			}

			.r {
				image {
					width: 45rpx;
					height: 42rpx;
				}
			}

			.wallet {
				width: calc(100% - 60rpx);
				height: 240rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
				border-radius: 20rpx;

				.top_box1 {
					display: flex;
					padding: 10rpx 30rpx;
					justify-content: space-between;
					align-items: center;

					.l {
						display: flex;

						.text {
							font-size: 30rpx;
							font-family: Microsoft YaHei;
							color: #333333;
						}

						image {
							margin-left: 10rpx;
							width: 24rpx;
							height: 18rpx;
						}
					}

					.r {
						display: flex;

						.button {
							padding: 12rpx 30rpx;
							background: #FFFFFF;
							// border: 2rpx solid #5990FF;
							border-radius: 25rpx;
							text-align: center;
							font-size: 22rpx;
							font-family: Microsoft YaHei;
							color: #5990FF;
						}
					}

				}

				.wallet_box {
					width: 100%;
					display: flex;
					justify-content: space-between;
					padding: 30rpx;
					padding-top: 0;

					.wallet_item {
						width: 50%;

						view:nth-child(1) {
							font-size: 30rpx;
							font-family: Microsoft YaHei;
							font-weight: bold;
							color: #333333;
						}

						view:nth-child(2) {
							margin-top: 10rpx;
							font-size: 30rpx;
							font-family: Microsoft YaHei;
							font-weight: bold;
							color: #333333;

						}
						
					}
				}

			}

			.ab {
				position: absolute;
				left: 30rpx;
				bottom: -100rpx;
			}
		}
	}

	.wallet1 {
		width: calc(100% - 60rpx);
		height: 200rpx;
		margin:20rpx 30rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
		border-radius: 20rpx;

		.top_box1 {
			display: flex;
			padding: 20rpx 30rpx;
			justify-content: space-between;
			align-items: center;

			.l {
				display: flex;

				.text {
					font-size: 28rpx;
					font-family: Microsoft YaHei;
					font-weight: bold;
					color: #333333;
				}

				image {
					margin-left: 10rpx;
					width: 24rpx;
					height: 18rpx;
				}
			}

			.r {
				display: flex;

				.button {
					padding: 12rpx 30rpx;
					background: #FFFFFF;
					// border: 2rpx solid #5990FF;
					border-radius: 25rpx;
					text-align: center;
					font-size: 28rpx;
					font-family: Microsoft YaHei;
					color: #5990FF;
				}
			}

		}

		.wallet_box {
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 30rpx;
			padding-bottom: 15rpx;
			padding-top: 0;

			.wallet_item {
				width: 50%;
				text-align: center;
				view:nth-child(1) {
					font-size: 28rpx;
					font-family: Microsoft YaHei;
					color: #333333;
				}

				view:nth-child(2) {
					margin-top: 10rpx;
					font-size: 28rpx;
					font-family: Microsoft YaHei;
					color: #333333;
					
				}
				image{
					width: 50rpx;
					height: 50rpx;
				}
			}
		}

	}

	.imgs_box {
		display: flex;
		justify-content: space-between;
		padding: 20rpx 30rpx;

		image {
			width: 330rpx;
			height: 160rpx;
			box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
			border-radius: 10rpx;
		}
	}

	.user_content {
		margin: 0 30rpx;
		padding: 20rpx 0;
		display: flex;
		justify-content: center;
		background: #FFFFFF;
		box-shadow: 0px 0px 20rpx 0px rgba(0, 0, 0, 0.1);
		border-radius: 20rpx;

		.user_item {
			width: 20%;
			text-align: center;
			margin-right: 30rpx;

			image {
				width: 80rpx;
				height: 80rpx;
			}

			.text {
				color: #333333;
				font-size: 24rpx;
			}
		}
	}

	.user_content1 {
		margin: 30rpx;
		padding: 25rpx 0;
		display: flex;
		box-sizing: border-box;
		background: #FFFFFF;
		box-shadow: 0px 0px 20rpx 0px rgba(0, 0, 0, 0.1);
		border-radius: 20rpx;
		flex-wrap: wrap;

		.user_item {
			width: 25%;
			text-align: center;
			margin-bottom: 20rpx;

			image {
				width: 80rpx;
				height: 80rpx;
			}

			.text {
				color: #333333;
				font-size: 28rpx;
			}
		}
	}

	.tj-sction {
		display: flex;
		align-items: center;
		justify-content: space-around;
		background: #FFFFFF;
		// box-shadow: 0px 0px 11px 0px rgb(0 0 0 / 10%);
		border-radius: 11px;
		margin: 0 16px;

		// @extend %section;
		.tj-item {
			// @extend %flex-center;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			height: 140upx;
			font-size: $font-sm;
			color: #75787d;
		}

		text {
			color: #75787d;
			font-size: 24rpx;
		}

		.num {
			font-size: 30rpx;
			color: #303133;
			margin-bottom: 8rpx;
		}
	}

	.order-section {
		display: flex;
		align-items: center;
		justify-content: space-around;
		background: #FFFFFF;
		// box-shadow: 0px 0px 11px 0px rgb(0 0 0 / 10%);
		border-radius: 11px;
		margin: 0 16px;
		padding: 28upx 0;
		margin-top: 20upx;

		.order-item {
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			width: 120upx;
			height: 120upx;
			border-radius: 10upx;
			font-size: $font-sm;
			color: $font-color-dark;
		}

		.yticon {
			font-size: 48upx;
			margin-bottom: 18upx;
			color: $base-color;
		}

		.icon-shouhoutuikuan {
			font-size: 44upx;
		}
	}
	.vip_box{
		position: relative;
		.vip-card-box {
			display: flex;
			justify-content: space-between;
			color: #f7d680;
			height: 40px;
			background: linear-gradient(left, rgba(0, 0, 0, .7), rgba(0, 0, 0, .8));
			border-radius: 8px 8px 0 0;
			width: calc(100% - 32px);
			box-sizing: border-box;
			background: -webkit-linear-gradient(left, rgba(0, 0, 0, .7), rgba(0, 0, 0, .8));
			padding: 5px 12px;
			margin: 0 16px;
			text:nth-child(2){
				font-size: 24rpx;
			}
		}
		.vip_bg{
			position: absolute;
			left: 0px;
			bottom: 0;
		}
	}
	
	
</style>
